package com.senven.api.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.senven.api.commom.ResponsePage;
import com.senven.api.dao.StuActivityMapper;
import com.senven.api.pojo.StuActivity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能描述:
 *
 * @Author YJF
 *
 */
@Service
public class StuActivityService {
    @Autowired
    private StuActivityMapper stuActivityMapper;

    public ResponsePage<StuActivity> queryStuActivityList(int current, int size){
        Page<StuActivity> page = new Page<StuActivity>(current, size);
        QueryWrapper<StuActivity> wrapper = new QueryWrapper<StuActivity>();
        IPage<StuActivity> iPage = stuActivityMapper.selectPage(page, null);
        ResponsePage<StuActivity> responsePage= new ResponsePage<StuActivity>();
        responsePage.makePage(iPage);
        return responsePage;
    }

    /**
     * 加入一个活动报名的信息
     * @param stuActivity
     * @return
     */
    public int insertStuActivity(StuActivity stuActivity){return stuActivityMapper.insertStuActivity(stuActivity);};



    /**
     *
     * 删除一个活动报名的信息
     */
    public int deleteStuActivity(int aid){
        return stuActivityMapper.deleteStuActivity(aid);
    }



    /**
     *根据aid查询报名活动的学生
     * @param aid
     * @return
     */
    public StuActivity queryStuActivityListByAId(int aid){
        return stuActivityMapper.queryStuActivityListByAId(aid);
    }
}
